package com.jiao.store.service.impl;

import com.jiao.store.entity.Product;
import com.jiao.store.mapper.ProductMapper;
import com.jiao.store.service.ProductService;
import com.jiao.store.service.ex.ProductServiceException;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class ProductServiceImpl implements ProductService {


    @Autowired
    private ProductMapper mapper;
    @Override
    public List<Product> FindHostList() {
        List<Product> hostList = mapper.findHostList();
        return  hostList;
    }

    @Override
    public Product findById(Integer id) {
        Product byId = mapper.findById(id);

        if (byId==null){
            throw  new ProductServiceException("商品异常");
        }

        return byId;
    }
}
